<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
	</head>
	<body>
		<form class="layui-form" action="">
					<div class="layui-form-item">
						<label class="layui-form-label">采购部门</label>
						<div class="layui-input-block">
							<input type="text" name="purchasingDepartment" id="purchasingDepartment" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">计划日期</label>
						<div class="layui-input-block">
							<input type="text" name="purchasingplanDate" id="purchasingplanDate" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">计划人</label>
						<div class="layui-input-block">
							<input type="text" name="planerId" id="planerId" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">录入日期</label>
						<div class="layui-input-block">
							<input type="text" name="createDate" id="createDate" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">审核者</label>
						<div class="layui-input-block">
							<select  name="inspectorId" id="inspectorId" lay-search>
							  <option value=""></option>
							</select>  
							<!--<input type="text" name="inspectorId" id="inspectorId" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">-->
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<input type="text" name="reamrks" id="reamrks"  placeholder="请输入标题" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		<table id="demo" lay-filter="test"></table>
		
		<script src="../../layui/layui.js"></script>
		<script src="../../js/User.js" type="text/javascript" charset="utf-8"></script>
		<script>
					//Demo
					layui.use(['form', 'laydate'], function() {
		
						var form = layui.form;
						var laydate = layui.laydate;
						var $ = layui.$;
						laydate.render({
							elem: '#purchasingplanDate',
							type: 'datetime',
							trigger: 'click' //采用click弹出
								,
							calendar: true
		
						});
						laydate.render({
							elem: '#createDate',
							type: 'datetime',
							trigger: 'click' //采用click弹出
								,
							calendar: true
								
						});
						$.getJSON(globalData.server+"user/getUserAll",{
							page:1,
							limit:10
						
						},function(res){
							console.log(res);
							if (res.data.length>0) {
								for (var i = 0; i < res.data.length; i++) {
									$("#inspectorId").append(new Option(res.data[i].name,res.data[i].id));
								}
								form.render('select');
							}
						})
						//监听提交
						form.on('submit(formDemo)', function(data) {
							$.post(globalData.server+"Alarm/insert", data.field, function(obj) {
								if(obj.count > 0) {
									//假设这是iframe页
									var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
									parent.layer.close(index); //再执行关闭        
		
								}
							})
							return false;
						});
					});
				</script>
	</body>
</html>
